
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2465. -- [中山市选2009]小球 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2465: [中山市选2009]小球</h2><span class=green>Time Limit: </span>10 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>36&nbsp;&nbsp;<span class=green>Solved: </span>13<br>[<a href='submitpage.php?id=2465'>Submit</a>][<a href='problemstatus.php?id=2465'>Status</a>][<a href='bbs.php?id=2465'>Discuss</a>]</center><h2>Description</h2><div class=content><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>给定n个不同颜色的球，每个球都有一个分数，同时有m个瓶子，每个瓶子都有固定的容量。现在，你必须把球放到瓶子里面。请编程计算最多能放多少个球到这些瓶子里。</div></div><h2>Input</h2><div class=content><div style="text-indent: 21.2pt">输入包含多组数据。</div>
<div style="text-indent: 21.2pt">每组数据的第一行为两个整数n, m，分别表示球的个数和瓶子的个数。</div>
<div style="text-indent: 21.2pt">接下来的n行，每一行包含一个整数p，表示相应的球的分数。</div>
<div style="text-indent: 21.2pt">接下来的m行，每一行包含两个整数c和q, 分别表示每个瓶子的容量（最多能装多少个球）和分数上界（放进该瓶子的每个球的分数都不能超过去q）。</div>
<div style="text-indent: 21.2pt">当输入n，m均为0时，表示输入结束。</div></div><h2>Output</h2><div class=content><div style="text-indent: 21pt">对于每组数据，输出两个整数B和S，分别表示总共能放进瓶子里的球的最大数目，以及在这个前提下，放进瓶子里面的所有球的最大分数总和。B和S以空格隔开，每组答案独占一行。</div></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>2 1<br />
2<br />
3<br />
1 2<br />
2 2<br />
4<br />
5<br />
2 4<br />
2 5<br />
0 0<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>1 2<br />
2 9<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt; mso-char-indent-count: 2.0"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于全部的数据，有</span><span lang="EN-US"><font face="Times New Roman">1&lt;=n&lt;=200</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang="EN-US"><font face="Times New Roman">0&lt;=m&lt;=200</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">1 &lt;= p &lt;= 10^6, 0 &lt;= c &lt;= 200, 1 &lt;= q &lt;= 10^6.</font></span></font></p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search='></a></p></div><center>[<a href='submitpage.php?id=2465'>Submit</a>][<a href='problemstatus.php?id=2465'>Status</a>][<a href='bbs.php?id=2465'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
